package com.example.orderservice2.dao;

import com.example.orderservice2.bean.Order;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderDao {
    @Select("select * from orders")
    List<Order> findAll();

    @Select("select * from orders where id = #{id}")
    Order findById(Long id);

    @Insert("insert into orders(product_id, quantity, status) values(#{productId}, #{quantity}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Order order);

    @Update("update orders set status=#{status} where id=#{id}")
    int updateStatus(@Param("id") Long id, @Param("status") String status);
}